import { FileIoUtil } from "./FileIOUtil";
import { Main } from "../Main";

/**
 * 配置工具
 * @author 赵占涛
 */
export class ConfigUtil {
    static load(cb: () => void) {
        console.log("projpath", Main.projPath);
        FileIoUtil.readFile(Main.projPath + "easyscript/config/MergePicCfg.json", (data) => {
            this.MergePicCfg = JSON.parse(data.toString());
            FileIoUtil.readFile(Main.projPath + "easyscript/config/NoCompressPicCfg.json", (data) => {
                this.NoCompressPicCfg = JSON.parse(data.toString());
                FileIoUtil.readFile(Main.projPath + "easyscript/config/PlatCfg.json", (data) => {
                    this.PlatCfg = JSON.parse(data.toString());
                    FileIoUtil.readFile(Main.projPath + "easyscript/config/NoPkmPvrCfg.json", (data) => {
                        this.NoPkmPvrCfg = JSON.parse(data.toString());
                        cb();
                    });
                });
            });
        });
    }
    static MergePicCfg: { dirs: string[] };
    static NoPkmPvrCfg: { dirs: string[] };
    static NoCompressPicCfg: { dirs: string[] };
    static PlatCfg: {
        [key: string]: {
            updateGateUrl: string,
            updateCdnUrl: string,
            sshServer: {
                host: string,
                port: string,
                username: string
            },
            defaultLanguage:string,
            language: {
                [language:string]:true
            }
        }
    };
}